package com.caimore;

import com.caimore.FFSMSSdk;
import com.caimore.entity.SMSRecvMsg;
import com.caimore.logger.Logger;
import java.text.SimpleDateFormat;
import java.util.ArrayList;

public class CMSMSSdkTest {

   public static void main(String[] args) {
      final FFSMSSdk oFFSMSSdk = new FFSMSSdk("COM5", 115200);

      try {
         boolean t1 = oFFSMSSdk.startSMSServer();
         if(t1) {
            Logger.info(" is start success");
         } else {
            Logger.info(" is start false");
         }

//         boolean bSend = oFFSMSSdk.sendSMSMsg("This is test context 12341", "18647979440");
//         Logger.info("[FFSMSSdkDemo]bSend: " + bSend);
      } catch (Exception var4) {
         Logger.info("[FFSMSSdkDemo]Exception  " + var4.getMessage());
      }

      Thread t11 = new Thread() {
         public void run() {
            while(true) {
               try {
                  Logger.info("[FFSMSSdkDemo]getLastError: " + oFFSMSSdk.getLastError());
                  ArrayList<SMSRecvMsg> ex = oFFSMSSdk.recvSMSMsg();
                  if(ex != null && ex.size() > 0) {
                     for(int i = 0; i < ex.size(); ++i) {
                        SMSRecvMsg oSMSMessage = (SMSRecvMsg)ex.get(i);
                        Logger.info("[FFSMSSdkDemo]得到短信猫接收短信的信息   Context = " + oSMSMessage.Msg + " time=" + oSMSMessage.RecvTime + "  phnoeNo= " + oSMSMessage.Phone);
                     }
                  }

                  Thread.sleep(1000L);
               } catch (InterruptedException var4) {
                  Logger.info("[FFSMSSdkDemo]InterruptedException  " + var4.getMessage());
               }
            }
         }
      };
      t11.start();
   }

   public static String genNowTimeString() {
      long ltime = System.currentTimeMillis();
      SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      String sDayTime = df.format(Long.valueOf(ltime));
      sDayTime = sDayTime.substring(2, sDayTime.length());
      return sDayTime;
   }
}
